package swing.samples.java2sdotcom.JFrameWindow;

import java.awt.GraphicsEnvironment;
import java.awt.Point;

import javax.swing.JFrame;

/**
 * @Title: CenteringaWindow.java
 * @Description: TODO(添加描述)
 * @author H819
 * @date 2010-10-10
 * @version V1.0
 */
public class CenteringaWindow {
	public static void main(String[] args) {
		JFrame aWindow = new JFrame("这是一个屏幕居中的窗口");
		Point center = GraphicsEnvironment.getLocalGraphicsEnvironment()
				.getCenterPoint();
		int windowWidth = 400;
		int windowHeight = 150;
		// set position and size
		aWindow.setBounds(center.x - windowWidth / 2, center.y - windowHeight
				/ 2, windowWidth, windowHeight);
		aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		aWindow.setVisible(true); // Display the window
	}
}
